﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Wicresoft.SMS.Web.App_GlobalResources;

using Wicresoft.SMS.Data;

namespace Wicresoft.SMS.Web
{
    [AuthoriseImplement(typeof(OnlyCheckVisibleImpIAuthorise))]
    public class CommonMenuModel : BaseModelWithAuthorise
    {
        [AuthoriseFlag(AuthoriseFlag.page_sms_send)]
        [Display(Name = "Common_SMSSend", ResourceType = typeof(Resources))]
        public string LinkSendSMS { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_sms_template)]
        [Display(Name = "Common_SMSTemplate", ResourceType = typeof(Resources))]
        public string LinkSMSTemplate { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_addressbook)]
        [Display(Name = "Common_AddressBook", ResourceType = typeof(Resources))]
        public string LinkAddressBook { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_history)]
        [Display(Name = "Common_History", ResourceType = typeof(Resources))]
        public string LinkHistory{ get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_history)]
        [Display(Name = "Common_History_Pending", ResourceType = typeof(Resources))]
        public string LinkHistoryPending { get; set; }


        [AuthoriseFlag(AuthoriseFlag.page_history)]
        [Display(Name = "Common_History_Delivered", ResourceType = typeof(Resources))]
        public string LinkHistoryDelivered { get; set; }


        [AuthoriseFlag(AuthoriseFlag.page_history)]
        [Display(Name = "Common_History_Failed", ResourceType = typeof(Resources))]
        public string LinkHistoryFailed { get; set; }


        [AuthoriseFlag(AuthoriseFlag.page_usermanage)]
        [Display(Name = "Common_ManageUser", ResourceType = typeof(Resources))]
        public string LinkManageUser { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_groupmanage)]
        [Display(Name = "Common_Managegroup", ResourceType = typeof(Resources))]
        public string LinkManageGroup { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_report_overview)]
        [Display(Name = "Common_SystemReport", ResourceType = typeof(Resources))]
        public string LinkSystemReport { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_report_overview)]
        [Display(Name = "Common_SystemReport_Overview", ResourceType = typeof(Resources))]
        public string LinkSystemReportOverview { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_report_history)]
        [Display(Name = "Common_SystemReport_Historyreport", ResourceType = typeof(Resources))]
        public string LinkSystemReportHistory { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_report_group)]
        [Display(Name = "Common_Systemreport_Groupreport", ResourceType = typeof(Resources))]
        public string LinkSystemReportGroup { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_report_user)]
        [Display(Name = "Common_SystemReport_Individualreport", ResourceType = typeof(Resources))]
        public string LinkSystemReportUser { get; set; }

        [AuthoriseFlag(AuthoriseFlag.page_report_user)]
        [Display(Name = "Common_SystemReport_Userinfo", ResourceType = typeof(Resources))]
        public string LinkSystemReportUserInfo { get; set; }

        public int IsActive { get; set; }

        public List<DepartmentInfo> Departments = new List<DepartmentInfo>();
        public void LoadDepartments(IEnumerable<Department> departments)
        {
            if (departments != null){
                foreach (var d in departments)
                    Departments.Add(new DepartmentInfo(d));
            }
        }
    }

    public class DepartmentInfo
    {
        public int departmentId { get; set; }
        public string departmentAlias { get; set; }
        public string departmentDisplay { get; set; }
        public DepartmentInfo() { }
        public DepartmentInfo(Department department)
        {
            departmentId = department.DepartmentID;
            departmentAlias = department.DepartmentName;
            departmentDisplay = department.DepartmentName;
        }

    }

}